package com.slofzx.nuoda.evaluation.project.controller;

import com.slofzx.nuoda.evaluation.project.dto.ExportTemplateDetailDTO;
import com.slofzx.nuoda.evaluation.project.service.IndexService;
import com.slofzx.nuoda.evaluation.project.vo.ExportTemplateDetailVO;
import com.slofzx.nuoda.evaluation.project.service.ExportTemplateDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.slofzx.nuoda.common.controller.BaseController;
import com.slofzx.nuoda.common.vo.AjaxResultVO;
import com.slofzx.nuoda.common.vo.PageResultVO;
import com.slofzx.nuoda.common.enums.ServiceResult;

import java.util.*;

import javax.annotation.Resource;

/**
 * 模版详情表控制层
 *
 * @author nuoda
 * @menu 模版详情表
 * @since 2024-02-29 08:36:54
 */
@RestController
@RequestMapping("/template/detail")
public class ExportTemplateDetailController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private ExportTemplateDetailService exportTemplateDetailService;

    /**
     * 通过查询条件查询列表数据
     *
     * @param dto 查询参数
     * @return 列表数据
     */
    @GetMapping("/data")
    public AjaxResultVO<List<ExportTemplateDetailVO>> queryList(ExportTemplateDetailDTO dto) {
        List<ExportTemplateDetailVO> dataList = exportTemplateDetailService.queryList(dto);
        return AjaxResultVO.newSuccessResult(dataList);
    }

    /**
     * 创建数据
     *
     * @param dto 参数数据
     * @return 操作结果
     */
    @ResponseBody
    @PostMapping(value = "/create")
    public AjaxResultVO create(@RequestBody ExportTemplateDetailDTO dto) {
        ServiceResult resultEnum = exportTemplateDetailService.create(dto);
        return AjaxResultVO.getInstance(resultEnum);
    }

    /**
     * 数据更新
     *
     * @param dto
     * @return 操作结果
     */
    @ResponseBody
    @PostMapping(value = "/update")
    public AjaxResultVO update(@RequestBody ExportTemplateDetailDTO dto) {
        ServiceResult resultEnum = exportTemplateDetailService.update(dto);
        return AjaxResultVO.getInstance(resultEnum);
    }

    /**
     * 删除数据
     *
     * @param id
     * @return 操作结果
     */
    @ResponseBody
    @PostMapping(value = "/delete")
    public AjaxResultVO delete(@RequestParam String id) {
        ServiceResult resultEnum = exportTemplateDetailService.deleteById(id);
        return AjaxResultVO.getInstance(resultEnum);
    }

    /**
     * 上移数据
     *
     * @param id
     * @return 操作结果
     */
    @ResponseBody
    @PostMapping(value = "/moveUp")
    public AjaxResultVO moveUp(@RequestParam String id) {
        ServiceResult resultEnum = exportTemplateDetailService.moveUp(id);
        return AjaxResultVO.getInstance(resultEnum);
    }

    /**
     * 下移数据
     *
     * @param id
     * @return 操作结果
     */
    @ResponseBody
    @PostMapping(value = "/moveDown")
    public AjaxResultVO moveDown(@RequestParam String id) {
        ServiceResult resultEnum = exportTemplateDetailService.moveDown(id);
        return AjaxResultVO.getInstance(resultEnum);
    }

    /**
     * 查询单个数据
     *
     * @return id对应数据
     */
    @ResponseBody
    @GetMapping(value = "/info/{id}")
    public AjaxResultVO<ExportTemplateDetailVO> queryById(@PathVariable String id) {
        ExportTemplateDetailVO vo = exportTemplateDetailService.queryById(id);
        return AjaxResultVO.newSuccessResult(vo);
    }

}
